#include <glib/gi18n.h>
+static gboolean print_packfile;
static gboolean print_compose;
static char* print_variant_type;
static GOptionEntry options[] = {
+ { "print-packfile", 0, 0, G_OPTION_ARG_NONE, &print_packfile, "If given, argument given is a packfile", NULL },
{ "print-compose", 0, 0, G_OPTION_ARG_NONE, &print_compose, "If given, show the branches which make up the given compose commit", NULL },
{ "print-variant-type", 0, 0, G_OPTION_ARG_STRING, &print_variant_type, "If given, argument should be a filename and it will be interpreted as this type", NULL },
{ NULL }
print_variant (GVariant *variant)
{
char *formatted_variant = NULL;
+ GVariant *byteswapped = NULL;
- formatted_variant = g_variant_print (variant, TRUE);
+ if (G_BYTE_ORDER != G_BIG_ENDIAN)
+ {
+ byteswapped = g_variant_byteswap (variant);
+ formatted_variant = g_variant_print (byteswapped, TRUE);
+ }
+ else
+ {
+ formatted_variant = g_variant_print (variant, TRUE);
+ }
g_print ("%s\n", formatted_variant);
g_free (formatted_variant);
+ if (byteswapped)
+ g_variant_unref (byteswapped);
}
static gboolean
return ret;
}
+static gboolean
+do_print_packfile (OstreeRepo *repo,
+ const char *checksum,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ GVariant *variant = NULL;
+ char *path = NULL;
+ GInputStream *content = NULL;
+ GFile *file = NULL;
+
+ path = ostree_repo_get_object_path (repo, checksum, OSTREE_OBJECT_TYPE_FILE);
+ if (!path)
+ goto out;
+ file = ot_util_new_file_for_path (path);
+
+ if (!ostree_parse_packed_file (file, &variant, &content, NULL, error))
+ goto out;
+
+ print_variant (variant);
+
+ ret = TRUE;
+ out:
+ g_free (path);
+ g_clear_object (&file);
+ g_clear_object (&content);
+ if (variant)
+ g_variant_unref (variant);
+ return ret;
+}
+
static gboolean
do_print_compose (OstreeRepo *repo,
const char *rev,
if (argc > 1)
rev = argv[1];
- if (print_compose)
+ if (print_packfile)
+ {
+ if (!do_print_packfile (repo, rev, error))
+ goto out;
+ }
+ else if (print_compose)
{
if (!ostree_repo_resolve_rev (repo, rev, &resolved_rev, error))
goto out;